#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <time.h>
#include <stdlib.h>
using namespace std;
struct Model{
    string inAdvance;
    string s2;
    double magnitude;
    string place;
    double time;
    string title;
    float depth;
    pair<double,double>coord;
    float weight;
    string json;
    Model(double mag,string pla,double tim,string tit,float dep,double lon,double lat,float w):magnitude(mag),place(pla),time(tim),depth(dep),title(tit),weight(w){
        coord.first=lon;
        coord.second=lat;
        inAdvance="{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[";
        s2="]},\"properties\":{\"mag\":"+to_string(magnitude)+",\"place\":\""+place+"\",\"time\":"+to_string(time)+",\"title\":\""+title+"\",\"depth\":"+to_string(depth)+"}}";
        json=inAdvance+to_string(coord.first)+","+to_string(coord.second)+","+to_string(weight)+s2;
    }
};
int main(){
    srand(time(0));
    ifstream ifs("arcgis/usgs-earthquakes-06182019.geojson",ios::in);
    if(!ifs)return -1;
    string s;
    while(getline(ifs,s)){
        cout<<s<<endl;
    }
    Model m0(4.6,"OV",1560962164830,"Palaca",6.6,114.39198865,30.50930137,4.4);
    Model m(3.2,"Wuhan",1558372915742,"WuhanHubei",6.3,114.39366883904,30.508393292,4.1);
    cout<<m.json<<endl;
    cout<<m0.json<<endl;
    ifs.close();
    ofstream ofs("data.geojson");
    double placetime=1560962164830;
    double CenterLon=114.39366883;
    double CenterLat=30.50839329;
    for(int i=0;i<100;i++){
        Model m(20.4,"Place"+to_string(i),placetime-10000000.0*i,"Title:Place "+to_string(i),6.0,CenterLon+(rand()%30)/100.0,CenterLat+(rand()%30)/100.0,0);
        ofs<<m.json<<endl;
    }
    ofs.close();
    return 0;
}